package com.ff.xyh.feign.client.userfront;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ff.xyh.common.entity.result.ResultMessage;
import com.ff.xyh.common.entity.userfront.*;
import com.ff.xyh.common.entity.result.ResultObject;
import com.ff.xyh.common.utils.JwtUtils;
import com.ff.xyh.common.utils.MD5;
import com.ff.xyh.common.vo.user.UserBaseInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

/**
 * @Auther FF
 * @Date 2022年 11月 04日
 * @Time 20:39
 */

@FeignClient(value = "service-user-front", contextId = "FrontUserClient")
@RequestMapping("/front-user")
public interface FrontUserClient{

    /**
     * 登录 前端需要把token写入cookie 发送请求时作为请求头
     * @param userToken
     * @param password
     * @return
     */
    @PostMapping("login")
    ResultObject login(
            @RequestParam(name = "userToken", required = false) String userToken,
            @RequestParam(name = "password", required = false) String password) ;

    @PostMapping("login-token")
    ResultObject loginWithToken(
            @RequestParam(name = "token") String token) ;


    /**
     * 注册
     * @param frontUser
     * @return
     */
    @PostMapping("register")
    ResultObject register (
            @RequestBody(required = false) FrontUser frontUser) ;


    /**
     * 通过openid获取对象
     * @param openid
     * @return
     */
    @GetMapping("get-user-open-id")
    ResultObject getUserByOpenid (
            @RequestParam(name = "openid") String openid) ;

    @GetMapping("get-user-base-id")
    ResultObject getUserBaseInfoById(@RequestParam(name = "id") String id ) ;

    /**
     * 通过 ids 批量获取用户基本信息
     * @param userIds
     * @return
     */
    @GetMapping("get-user-base-ids")
    ResultObject getUserBaseInfosByIds(
            @RequestParam(name = "ids") List<String> userIds ) ;

    /**
     * 通过id查询用户所有信息
     * @param id
     * @return
     */
    @GetMapping("get-user-id")
    ResultObject getUserById (
            @RequestParam(name = "id", required = false) String id ) ;
    @GetMapping("get-user-username")
    ResultObject getUserWithUsername(
            @RequestParam(name = "username") String username) ;
    @GetMapping("get-user-sno")
    ResultObject getUserWithSno(
            @RequestParam(name = "sno") String sno) ;
    @GetMapping("get-user-email")
    ResultObject getUserWithEmail(
            @RequestParam(name = "email") String email) ;
    @GetMapping("get-user-phone")
    ResultObject getUserWithPhone(
            @RequestParam(name = "phone") String phone) ;

    @GetMapping("has-user-username")
    ResultObject hasUserUsername(
            @RequestParam(name = "username") String username) ;
    @GetMapping("has-user-sno")
    ResultObject hasUserSno(
            @RequestParam(name = "sno") String sno) ;
    @GetMapping("has-user-email")
    ResultObject hasUserEmail(
            @RequestParam(name = "email") String email) ;
    @GetMapping("has-user-phone")
    ResultObject hasUserPhone(
            @RequestParam(name = "phone") String phone) ;

    /**
     * 更新用户信息
     * @param frontUser
     * @return
     */
    @PostMapping("update-user")
    ResultObject updateUser (
            @RequestBody FrontUser frontUser) ;

    /**
     * 根据userId更新用户最后在线时间
     * 没有返回用户时表示用户不存在
     * @param id
     * @return
     */
    @PostMapping("update-user-lastLog-id")
    ResultObject updateUserLastLogById (
            @RequestParam(name = "id") String id) ;

    /**
     * 用户修改密码
     * @param password
     * @param request
     * @return
     */
    @GetMapping("update-user-password-token")
    ResultObject updateUserPasswordWithToken (
            @RequestParam(name = "password") String password,
            HttpServletRequest request) ;

    // 使用消费者进行删除 消费者 删除该用户时 需要同时删除用户的收藏表 拉黑表 删除用户为最高权限操作，非常规操作 封号才需要操作员
    @GetMapping("delete-user-id")
    ResultObject deleteUserById (
            @RequestParam(name = "id", required = false) String id) ;

}


